using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content.Pipeline;
using Microsoft.Xna.Framework.Content.Pipeline.Graphics;
using Microsoft.Xna.Framework.Content.Pipeline.Processors;

// TODO: replace these with the processor input and output types.
using TInput = System.String;
using TOutput = System.String;
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
using Microsoft.Xna.Framework.Content;
using System.Xml.Serialization;

namespace Dragoon.BreakIt.Data
{
    /// <summary>
    /// This class will be instantiated by the XNA Framework Content Pipeline
    /// to apply custom processing to content data, converting an object of
    /// type TInput to TOutput. The input and output types may be the same if
    /// the processor wishes to alter data without changing its type.
    ///
    /// This should be part of a Content Pipeline Extension Library project.
    ///
    /// TODO: change the ContentProcessor attribute to specify the correct
    /// display name for this processor.
    /// </summary>
    [ContentProcessor(DisplayName = "BreakItPipeline.ContentProcessor1")]
    public class ContentProcessor1 : ContentProcessor<TInput, TOutput>
    {
        public override TOutput Process(TInput input, ContentProcessorContext context)
        {
            // TODO: process the input object, and return the modified data.
            throw new NotImplementedException();
        }

    }

    [ContentTypeWriter]
    public class ConfigurationWriter : ContentTypeWriter<Configuration>
    {
        protected override void Write(ContentWriter output, Configuration value)
        {
            XmlSerializer ser = new XmlSerializer(typeof(Configuration));
            ser.Serialize(output.BaseStream, value);
        }

        public override string GetRuntimeReader(TargetPlatform targetPlatform)
        {
            return typeof(ConfigurationReader).AssemblyQualifiedName;
        }
    }

    public class ConfigurationReader : ContentTypeReader<Configuration>
    {
        protected override Configuration Read(ContentReader input, Configuration existingInstance)
        {
            Configuration config = new Configuration();
            XmlSerializer ser = new XmlSerializer(typeof(Configuration));
            return (Configuration)ser.Deserialize(input.BaseStream);
        }
    }

}